<template>
  <div class="page">
    <h1>登录页</h1>
    <input v-model="username" placeholder="用户名" />
    <button @click="login">登录</button>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'

const username = ref('')
const router = useRouter()

function login() {
  if (username.value.trim()) {
    localStorage.setItem('token', 'mock_token')
    router.push('/')
  } else {
    alert('请输入用户名')
  }
}
</script>
